home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6967 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  50 lines

  1. Path: sun001.spd.dsccc.com!spd!jmccarty
  2. From: jmccarty@spd.dsccc.com (Mike McCarty)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: C constant expression declarations
  5. Date: 16 Feb 1996 19:56:26 GMT
  6. Organization: DSC Communications Corporation, Plano, Texas USA
  7. Message-ID: <4g2nha$ksa@sun001.spd.dsccc.com>
  8. References: <31229735.41C67EA6@isi.com> <4fvl5cINN94q@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: aplo139.spd.dsccc.com
  10.  
  11. In article <4fvl5cINN94q@keats.ugrad.cs.ubc.ca>,
  12. Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
  13. )In article <31229735.41C67EA6@isi.com>, J.R. Stoner <jstoner@isi.com> wrote:
  14. )>This is a query (I have checked the FAQ) into something that strikes me
  15. )>as a dumbfoundedly stupid issue, but I will ask it anyway :)
  16. )>
  17. )>Normally, I will do things such as:
  18. )>
  19. )> #define EXPR1   1
  20. )> #define EXPR2   2
  21. )>
  22. )>...and so on.  Lately, I have been observing in code from other people
  23. )>equivalent declarations such as:
  24. )>
  25. )> #define EXPR1   (1)
  26. )> #define EXPR2   (2)
  27. )
  28. )This does not buy you anything at all, since the thing you are bracketing
  29. )has only one constituent: it's not a compound expression.
  30.  
  31. I respectfully disagree with this statement. It buys two very important
  32. things, to wit:
  33.  
  34.     it builds a good habit of putting parens in, so that when they
  35.         are needed they don't inadvertently get left out
  36.  
  37.     it builds consistency, so that one gets a feeling that
  38.         "something may be wrong here" when inspecting code for
  39.         errors 
  40.  
  41. I believe that (for the sake of creating and maintaining correct
  42. programs) these are well worth the extra discipline (at first) and
  43. compilation time for the cases where the parens are not strictly needed.
  44.  
  45. Mike
  46. ----
  47. char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
  48.  
  49. I don't speak for DSC.         <- They make me say that.
  50.